#include "messagearea.h"
#include "ui_messagearea.h"

MessageArea::MessageArea(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MessageArea)
{
    ui->setupUi(this);

    ringIsFist=true;
    ui->pushButton->setChecked(SettingParser::getInstance()->getValue("newmessagering").toInt());
    ui->pushButton_2->setChecked(SettingParser::getInstance()->getValue("voicecallring").toInt());
    ui->pushButton_3->setChecked(SettingParser::getInstance()->getValue("videocallring").toInt());
    ui->comboBox->setCurrentIndex(SettingParser::getInstance()->getValue("ring").toInt());
}

MessageArea::~MessageArea()
{
    delete ui;
}

void MessageArea::on_pushButton_clicked(bool checked)
{
    qDebug()<<"btn triggered";
    SettingParser::getInstance()->setValue("newmessagering",QString::number(checked));
}

void MessageArea::on_pushButton_2_clicked(bool checked)
{
    qDebug()<<"btn2 triggered";

    SettingParser::getInstance()->setValue("voicecallring",QString::number(checked));

}

void MessageArea::on_pushButton_3_clicked(bool checked)
{
    qDebug()<<"btn3 triggered";

    SettingParser::getInstance()->setValue("videocallring",QString::number(checked));
}

//注，页面初始化时该槽函数会调用
void MessageArea::on_comboBox_currentIndexChanged(int index)
{
    if(ringIsFist)
    {
        ringIsFist=false;
        return;
    }
    SettingParser::getInstance()->setValue("ring",QString::number(index));
}
